package com.bskj.bms.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.bskj.bms.service.IBmsInstallService;
import com.bskj.common.bean.model.NoCarnoParkRate;

@Controller
@RequestMapping("/install")
public class InstallCotroller extends BaseController{
	
	@Autowired
	private IBmsInstallService bmsInstallService;
	
	@RequestMapping("/index")
	public ModelAndView index() throws Exception {
		ModelAndView mv=new ModelAndView();
		NoCarnoParkRate noCarnoParkRate=bmsInstallService.findRate(getSessionUser().getCustId());
		mv.addObject("noCarnoParkRate", noCarnoParkRate);
		mv.setViewName("/install/ruleInstall");
		return mv;
	}
	
	@ResponseBody
	@RequestMapping("rule")
	public Map<String, Object> rule(NoCarnoParkRate noCarnoParkRate) throws Exception{
		Map<String, Object> resultMap=new HashMap<>();
		noCarnoParkRate.setParkingLotCustId(getSessionUser().getCustId());
		resultMap=bmsInstallService.updateOrInsert(noCarnoParkRate);
		return  resultMap;
	}
}
